<template>
    <div class="card card-custom">
      <div class="card-body p-0">
        <!--begin: Wizard-->
        <div
          class="wizard wizard-1"
          id="kt_wizard_v1"
          data-wizard-state="step-first"
          data-wizard-clickable="true"
        >
          <!--begin: Wizard Nav-->
          <div class="wizard-nav border-bottom">
            <div class="wizard-steps p-8 p-lg-10">
              <div
                class="wizard-step"
                data-wizard-type="step"
                data-wizard-state="current"
              >
                <div class="wizard-label">
                  <i class="wizard-icon flaticon-bus-stop"></i>
                  <h3 class="wizard-title">1. 输入测量参数</h3>
                </div>
                <i class="wizard-arrow flaticon2-next"></i>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <i class="wizard-icon flaticon-list"></i>
                  <h3 class="wizard-title">2. 计算未调整前的功能点数</h3>
                </div>
                <i class="wizard-arrow flaticon2-next"></i>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <i class="wizard-icon flaticon-responsive"></i>
                  <h3 class="wizard-title">3. 判断复杂性等级</h3>
                </div>
                <i class="wizard-arrow flaticon2-next"></i>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <i class="wizard-icon flaticon-truck"></i>
                  <h3 class="wizard-title">4. 计算复杂度调整系数</h3>
                </div>
                <i class="wizard-arrow flaticon2-next"></i>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <i class="wizard-icon flaticon-globe"></i>
                  <h3 class="wizard-title">5. 计算FP(UFP*VAF)</h3>
                </div>
                <i class="wizard-arrow last flaticon2-next"></i>
              </div>
            </div>
          </div>
          <!--end: Wizard Nav-->
  
          <!--begin: Wizard Body-->
          <div class="row justify-content-center my-10 px-8 my-lg-15 px-lg-10">
            <div class="col-xl-12 col-xxl-7">
              <!--begin: Wizard Form-->
              <form class="form" id="kt_form">
                <!--begin: Wizard Step 1-->
                <div
                  class="pb-5"
                  data-wizard-type="step-content"
                  data-wizard-state="current"
                >
                  <h3 class="mb-10 font-weight-bold text-dark">
                    Input measurement parameters                
                  </h3>
                  <div class="form-group">
                    <label>enter file</label>
              <div>
                <!-- Styled -->
                <b-form-file
                  v-model="file"
                  :state="Boolean(file)"
                  placeholder="Choose a Xml file or drop it here..."
                  drop-placeholder="Drop file here..."
                ></b-form-file>
                <div class="mt-3">Selected file: {{ file ? file.name : "" }}</div>
              </div>
              <div>
          </div>
  
                    <!-- <input
                      type="text"
                      class="form-control form-control-solid form-control-lg"
                      name="address1"
                      placeholder="Address Line 1"
                      value="enter file"
                    /> -->
                    <!-- <span class="form-text text-muted"
                      >Please enter your file.</span
                    > -->
                    
                  </div>
                  <div class="form-group">
                    <div>
                     <label>加权功能点展示</label>
                     <!-- 点击按钮,获取文件Xml格式的file对象,调用函数读取文件内容并存储到变量中,并在表单里渲染 -->
                     <b-col lg="4" class="pb-2">
                        <b-button @click="OnShow()" size="sm">Show </b-button>
                     </b-col>                  
                   </div>
                    <div>
                      <b-table striped hover :items="item"></b-table>
                    </div>
                    <div>
                      <b-table striped hover :items="item2"></b-table>
                    </div>
                    <div>
                      <b-table striped hover :items="item3"></b-table>
                    </div>
                    <div>
                      <b-table striped hover :items="item4"></b-table>
                    </div>
                    <div>
                      <b-table striped hover :items="item5"></b-table>
                    </div>
            </div>
          </div>
                <!--end: Wizard Step 1-->
  
                <!--begin: Wizard Step 2-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Calculate the number of function points before adjustment
                  </h4>
  
                  <div class="row">
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>ILF内部逻辑文件</label>
                        <input 
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value = "calculateFP(this.item)"
                        />
                        <span class="form-text text-muted"
                          >Please enter your Package Width in CM.</span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>EIF外部接口文件</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="height"
                          placeholder="Package Length"
                          :value = "calculateFP(this.item2)"
                        />
                        <span class="form-text text-muted"
                          >Please enter your Package Height in CM.</span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>EI外部输入</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value = "calculateFP(this.item3)"
                        />
                        <span class="form-text text-muted"
                          >Please enter your Package Length in CM.</span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>EO外部输出</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value = "calculateFP(this.item4)"
                        />
                        <span class="form-text text-muted"
                          >Please enter your Package Length in CM.</span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>EQ外部查询</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value = "calculateFP(this.item5)"
                        />
                        <span class="form-text text-muted"
                          >Please enter your Package Length in CM.</span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>UFP</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value = "calculateTotal()"
                        />
                        <span class="form-text text-muted"
                          >Please enter your Package Length in CM.</span
                        >
                      </div>
                    </div>
                  </div>
                </div>
                <!--end: Wizard Step 2-->
  
                <!--begin: Wizard Step 3-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Determining technical complexity factors
                  </h4>
                  <div class="form-group">
                    <label>Data Communications</label>
                    <select
                      name="F1"
                      class="form-control form-control-solid form-control-lg"
                      v-model="DataCommunications"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Distributed Data process</label>
                    <select
                      name="F2"
                      class="form-control form-control-solid form-control-lg"
                      v-model="DistributedDataprocess"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Performance</label>
                    <select
                      name="F3"
                      class="form-control form-control-solid form-control-lg"
                      v-model="Performance"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Heavily Used Configuration</label>
                    <select
                      name="F4"
                      class="form-control form-control-solid form-control-lg"
                      v-model="HeavilyUsedConfiguration"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Transaction Rate</label>
                    <select
                      name="F5"
                      class="form-control form-control-solid form-control-lg"
                      v-model="TransactionRate"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Online Data Entry</label>
                    <select
                      name="F6"
                      class="form-control form-control-solid form-control-lg"
                      v-model="OnlineDataEntry"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>End-User efficiency</label>
                    <select
                      name="F7"
                      class="form-control form-control-solid form-control-lg"
                      v-model="EndUserefficiency"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Online Update</label>
                    <select
                      name="F8"
                      class="form-control form-control-solid form-control-lg"
                      v-model="OnlineUpdate"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Complex processing</label>
                    <select
                      name="F9"
                      class="form-control form-control-solid form-control-lg"
                      v-model="Complexprocessing"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Reusability</label>
                    <select
                      name="F10"
                      class="form-control form-control-solid form-control-lg"
                      v-model="Reusability"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Installation Ease</label>
                    <select
                      name="F11"
                      class="form-control form-control-solid form-control-lg"
                      v-model="InstallationEase"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Oparetional Ease</label>
                    <select
                      name="F12"
                      class="form-control form-control-solid form-control-lg"
                      v-model="OparetionalEase"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Multiple site</label>
                    <select
                      name="F13"
                      class="form-control form-control-solid form-control-lg"
                      v-model="Multiplesite"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Facilitate Change</label>
                    <select
                      name="F14"
                      class="form-control form-control-solid form-control-lg"
                      v-model="FacilitateChange"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                </div>
                <!--end: Wizard Step 3-->
  
                <!--begin: Wizard Step 4-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Calculate the number of function points before adjustment
                  </h4>
  
                  <div class="row">
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Data Communications</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="DataCommunications.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Distributed Data process</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="height"
                          placeholder="Package Length"
                          :value="DistributedDataprocess.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Performance</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value="Performance.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>HeavilyUsedConfiguration</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value="HeavilyUsedConfiguration.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Transaction Rate</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value="TransactionRate.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Online Data Entry</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="length"
                          placeholder="Package Length"
                          :value="OnlineDataEntry.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>End-User efficiency</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="EndUserefficiency.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Online Update</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="OnlineUpdate.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Complex processing</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="Complexprocessing.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Reusability</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="Reusability.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Installation Ease</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="InstallationEase.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Oparetional Ease</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="OparetionalEase.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Multiple site</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="Multiplesite.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>Facilitate Change</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="FacilitateChange.substr(0,1)"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                    <div class="col-xl-4">
                      <div class="form-group">
                        <label>VAF</label>
                        <input
                          type="text"
                          class="form-control form-control-solid form-control-lg"
                          name="width"
                          placeholder="Package Width"
                          :value="calculateVAF()"
                        />
                        <span class="form-text text-muted"
                          ></span
                        >
                      </div>
                    </div>
                  </div>
                </div>
                <!--end: Wizard Step 4-->
  
                <!--begin: Wizard Step 5-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Review your Details and Culculate the FP
                  </h4>
                  <div class="border-bottom mb-5 pb-5">
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                    <div class="font-weight-bold mb-3">
                      UFP:
                    </div>
                    <div class="line-height-md">
                      ILF_FP:{{calculateFP(this.item)}}<br />
                      EIF_FP:{{calculateFP(this.item2)}}<br />
                      EI_FP:{{calculateFP(this.item3)}}<br />
                      EO_FP:{{calculateFP(this.item4)}}<br />
                      EQ_FP:{{calculateFP(this.item5)}}<br />
                      UFP = ILF_FP+EIF_FP+EI_FP+EO_FP+EQ_FP={{ calculateTotal() }}
                      <br />
                    </div>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                    <div class="font-weight-bold mb-3">
                      VAF:
                    </div>
                    <div class="line-height-md">
                      VAF=0.65+∑(Ni/100)={{ calculateVAF() }}
                      <br />
                    </div>
                  </div>
                    <div class="font-weight-bold mb-3">
                      FP:
                    </div>
                    <div class="line-height-md">
                      FP=UFP*VAF={{calculateTotal()*calculateVAF()}}
                      <br />
                    </div>
                    <div class="border-bottom mb-5 pb-5">
                  </div>
                    <div style="margin-top: 2rem;margin-right: 2rem;margin-left: 2rem;">
                      <b-media>
                        <template v-slot:aside>
                          <!-- <b-img
                            src="media/stock-600x600/img-0.png"
                            width="50"
                          ></b-img> -->
                        </template>

                        <h5 class="mt-0">Analysis</h5>
                        <ul style="margin-left: 2rem;">
                          <li v-for="(item, index) in chatGPT.split('\n\n')" :key="index" style="margin-bottom: 0.8rem;">
                            {{ item }}
                          </li>
                        </ul>
                      </b-media>
                      </div>
                </div>
                <!--end: Wizard Step 5-->
  
                <!--begin: Wizard Actions -->
                <div class="d-flex justify-content-between border-top pt-10">
                  <div class="mr-2">
                    <button
                      class="btn btn-light-primary font-weight-bold text-uppercase px-9 py-4"
                      data-wizard-type="action-prev"
                    >
                      Previous
                    </button>
                  </div>
                  <div>
                    <button
                      v-on:click="submit"
                      class="btn btn-success font-weight-bold text-uppercase px-9 py-4"
                      data-wizard-type="action-submit"
                    >
                    Analyze
                    </button>
                    <button
                      class="btn btn-primary font-weight-bold text-uppercase px-9 py-4"
                      data-wizard-type="action-next"
                    >
                      Next Step
                    </button>
                  </div>
                </div>
                <!--end: Wizard Actions -->
              </form>
              <!--end: Wizard Form-->
            </div>
          </div>
          <!--end: Wizard Body-->
        </div>
      </div>
      <!--end: Wizard-->
    </div>
  </template>
  
  <style lang="scss">
  @import "@/assets/sass/pages/wizard/wizard-1.scss";
  </style>
  
  <script>
  import { SET_BREADCRUMB } from "@/core/services/store/breadcrumbs.module";
  import KTUtil from "@/assets/js/components/util";
  import KTWizard from "@/assets/js/components/wizard";
  import{ chatGPTAnalysis } from "@/api/fp.js";
  import Swal from "sweetalert2";
  let VAF = 0
  
  export default {
    name: "Wizard-1",
    data() {
       return {
        
        file: null,
        DataCommunications:"0 means no impact",
        DistributedDataprocess:"0 means no impact",
        Performance:"0 means no impact",
        HeavilyUsedConfiguration:"0 means no impact",
        TransactionRate:"0 means no impact",
        OnlineDataEntry:"0 means no impact",
        EndUserefficiency:"0 means no impact",
        OnlineUpdate:"0 means no impact",
        Complexprocessing:"0 means no impact",
        Reusability:"0 means no impact",
        InstallationEase:"0 means no impact",
        OparetionalEase:"0 means no impact",
        Multiplesite:"0 means no impact",
        FacilitateChange:"0 means no impact",
        //  item: [
        //    { ILF: '工资信息',  complex: '低',Unadjested_FP:5 }
        //  ],
        //  item2: [
        //    { EIF: '工资信息',  complex: '低',Unadjested_FP:5 }
        //  ],
        //  item3: [
        //    { EI: "添加员工信息",  complex: '高',Unadjested_FP:6 }
        //  ],
        //  item4: [
        //    { EO: "员工年薪统计",  complex: '平均',Unadjested_FP:5}
        //  ],
        //  item5: [
        //    { EQ: "查询员工信息",  complex: '高',Unadjested_FP:6 }
        //  ],
        item:[],
        item2:[],
        item3:[],
        item4:[],
        item5:[],
         list:[
          {id:0,value:"0 means no impact"},
          {id:1,value:"1 means small impact"},
          {id:2,value:"2 means mild impact"},
          {id:3,value:"3 means moderate impact"},
          {id:4,value:"4 means significant impact"},
          {id:5,value:"5 means major impact"}
         ],
         chatGPT : "AI分析还在进行中,请稍后。。。"
       }
     },
    mounted() {
      this.$store.dispatch(SET_BREADCRUMB, [
        { title: "功能点度量" },
        { title: "功能点度量" }
      ]);
  
      // Initialize form wizard
      const wizard = new KTWizard("kt_wizard_v1", {
        startStep: 1, // initial active step number
        clickableSteps: true // allow step clicking
      });
  
      // Validation before going to next page
      wizard.on("beforeNext", function(/*wizardObj*/) {
        // validate the form and use below function to stop the wizard's step
        // wizardObj.stop();
      });
  
      // Change event
      wizard.on("change", function(/*wizardObj*/) {
        setTimeout(() => {
          KTUtil.scrollTop();
        }, 500);
      });
    },
    methods: {
      FPAnalyze(){
        let message = [{"UFP":this.calculateTotal(),
                                "VAF":this.calculateVAF(),
                                "FP":this.calculateFP}]
                let formData2 = new FormData()
                formData2.append('FAResult', JSON.stringify(message))
                chatGPTAnalysis(formData2).then(resp => {
                    this.chatGPT = resp.data.MSG;
                })
      },
      submit: function(e) {
        this.FPAnalyze()
        e.preventDefault();
        Swal.fire({
          title: "",
          text: "The application has been successfully submitted!",
          icon: "success",
          confirmButtonClass: "btn btn-secondary"
        });
      },
       getUploadUrl: function(flie) {
       let url = "";
       if (window.createObjectURL != undefined) {
          url = window.createObjectURL(flie);
      } else if (window.webkitURL != undefined) {
          url = window.webkitURL.createObjectURL(flie);
      } else if (window.URL != undefined) {
          url = window.URL.createObjectURL(flie);
      }
      return url; 
     },
      loadXML: function(xmlFile) {
      var xmlDom = null;
      if (
          document.implementation &&
          document.implementation.createDocument
      ) {
          var xmlhttp = new window.XMLHttpRequest();
          xmlhttp.open("GET", xmlFile, false);
          xmlhttp.send(null);
          xmlDom = xmlhttp.responseXML;
      } else {
          xmlDom = null;
      }
      return xmlDom; 
     },
     OnShow(){
        console.log("获取,解析XML文件")
        this.item=[]
        this.item2=[]
        this.item3=[]
        this.item4=[]
        this.item5=[]
  
        let url = this.getUploadUrl(this.file); // 文件对象
        let xml = this.loadXML(url);
        let text = new XMLSerializer().serializeToString(xml) // 将text赋值给textarea阔以了
        console.log(text)
        let domParser = new DOMParser();
        let xmlDoc = domParser.parseFromString(text,'text/xml');
        console.log(xmlDoc);
        let elements = xmlDoc.getElementsByTagName("record");
        console.log(elements[0])
        var NameArray=["ILF","EIF","EI","EO","EQ"]
        for(var k=0;k<5;k++){
        for(var i=0;i<elements.length;i++){
           if(elements[i].getElementsByTagName(NameArray[k]) != null){
            for(var j=0;j<elements[i].getElementsByTagName(NameArray[k]).length;j++){
            var b =elements[i].getElementsByTagName(NameArray[k])
            var c =elements[i].getElementsByTagName("Complex")
            var d =elements[i].getElementsByTagName("Unadjested_FP")
            var temp ={}
            temp[NameArray[k]] = b[j].innerHTML
            temp["Complex"] = c[j].innerHTML
            temp["Unadjested_FP"] = d[j].innerHTML
            if(k == 0) {this.item.push(temp)}
            else if(k == 1){this.item2.push(temp)}
            else if(k == 2){this.item3.push(temp)}
            else if(k == 3){this.item4.push(temp)}
            else if(k == 4){this.item5.push(temp)}
            }
           }
        }
       }
      },
      calculateFP: function(Item){
        let FP = 0
        FP = parseInt(FP)
        for(var g=0;g<Item.length;g++){
          FP += parseInt(Item[g].Unadjested_FP)
        }
        return FP
     },
     calculateTotal: function(){
      let TotalFP = 0
      TotalFP = parseInt(TotalFP)
        for(var g=0;g<this.item.length;g++){
          TotalFP += parseInt(this.item[g].Unadjested_FP)
        }
        for(var q=0;q<this.item2.length;q++){
          TotalFP += parseInt(this.item2[q].Unadjested_FP)
        }
        for(var w=0;w<this.item3.length;w++){
          TotalFP += parseInt(this.item3[w].Unadjested_FP)
        }
        for(var e=0;e<this.item4.length;e++){
          TotalFP += parseInt(this.item4[e].Unadjested_FP)
        }
        for(var r=0;r<this.item5.length;r++){
          TotalFP += parseInt(this.item5[r].Unadjested_FP)
        }
        return TotalFP
     },
      selectedItemChange: function(event){
        if(event.target.name == "F1"){this.DataCommunications = event.target.value;}
        else if(event.target.name == "F2"){this.DistributedDataprocess = event.target.value;}
        else if(event.target.name == "F3"){this.Performance = event.target.value;}
        else if(event.target.name == "F4"){this.HeavilyUsedConfiguration = event.target.value;}
        else if(event.target.name == "F5"){this.TransactionRate = event.target.value;}
        else if(event.target.name == "F6"){this.OnlineDataEntry = event.target.value;}
        else if(event.target.name == "F7"){this.EndUserefficiency = event.target.value;}
        else if(event.target.name == "F8"){this.OnlineUpdate = event.target.value;}
        else if(event.target.name == "F9"){this.Complexprocessing = event.target.value;}
        else if(event.target.name == "F10"){this.Reusability = event.target.value;}
        else if(event.target.name == "F11"){this.InstallationEase = event.target.value;}
        else if(event.target.name == "F12"){this.OparetionalEase = event.target.value;}
        else if(event.target.name == "F13"){this.Multiplesite = event.target.value;}
        else {this.FacilitateChange = event.target.value;}
      },
      calculateVAF: function(){
        VAF=0
        VAF=0.65+parseInt(this.DataCommunications.substr(0,1))/100
        VAF+=parseInt(this.DistributedDataprocess.substr(0,1))/100
        VAF+=parseInt(this.Performance.substr(0,1))/100
        VAF+=parseInt(this.HeavilyUsedConfiguration.substr(0,1))/10
        VAF+=parseInt(this.TransactionRate.substr(0,1))/100
        VAF+=parseInt(this.OnlineDataEntry.substr(0,1))/100
        VAF+=parseInt(this.EndUserefficiency.substr(0,1))/100
        VAF+=parseInt(this.OnlineUpdate.substr(0,1))/100
        VAF+=parseInt(this.Complexprocessing.substr(0,1))/100
        VAF+=parseInt(this.Reusability.substr(0,1))/100
        VAF+=parseInt(this.InstallationEase.substr(0,1))/100
        VAF+=parseInt(this.OparetionalEase.substr(0,1))/100
        VAF+=parseInt(this.Multiplesite.substr(0,1))/100
        VAF+=parseInt(this.FacilitateChange.substr(0,1))/100
        return VAF
      }
    }
  };
  </script>
  